//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_POST_PROCESS_TYPES_H
#define _UX_POST_PROCESS_TYPES_H

#include "IPostProcess.h"
#include "../../Systems/Render/GLshell/AllGLshellTypes.h"

namespace Engine
{
namespace Resources
{

	
	struct TRenderTarget
	{
		string				sName;
		uint16				uTexType;
		e_rt_format::type	eTexFormat;
		float				fSize;
		uint				uWidth,
							uHeight,
							uDepth;
		e_tex_flags::type	eFlags;
		e_tex_swizzle::type	eSwizzle;
		uint8				uSamples;
		///
		TRenderTarget():
			uTexType(-1), eTexFormat(e_rt_format::UNKNOWN), fSize(0.f),
			uWidth(0), uHeight(0), uDepth(0), uSamples(0),
			eFlags(e_tex_flags::BILINEAR), eSwizzle(e_tex_swizzle::AUTO) {}
	};
	_CREATE_META_OBJECT_FD( TRenderTarget );


	struct TInputTexture
	{
		string				sName;
		e_pp_texture::type	eType;
		///
		TInputTexture(): eType(e_pp_texture::UNKNOWN) {}
	};
	_CREATE_META_OBJECT_FD( TInputTexture );


	struct TLoadedTexture
	{
		string				sName,
							sAddress;
		e_tex_flags::type	eFlags;
		e_pp_texture::type	eType;
		///
		TLoadedTexture(): eFlags(e_tex_flags::BILINEAR), eType(e_pp_texture::UNKNOWN) {}
	};
	_CREATE_META_OBJECT_FD( TLoadedTexture );


	struct TRTAttachParams
	{
		string				sName;
		e_fbo_attach::type	eAttach;
		uint				uLayer;
		uint				uLOD;
		///
		TRTAttachParams(): eAttach(e_fbo_attach::COLOR_0), uLayer(0), uLOD(0) {}
	};
	_CREATE_META_OBJECT_FD( TRTAttachParams );


	struct TTexBindParams
	{
		string				sName;
		e_texture::type		eType;
		///
		TTexBindParams(): eType(e_texture::UNKNOWN) {}
	};
	_CREATE_META_OBJECT_FD( TTexBindParams );


	struct TProgData
	{
		binary_buffer_t			aData;
		uint					uIndex;
		e_program_data::type	eType;
		///
		TProgData(): uIndex(-1), eType(e_program_data::UNKNOWN) {}
	};
	_CREATE_META_OBJECT_FD( TProgData );


	struct TPPPass
	{
		string					sProgram,
								sName;
		TGLRenderState			sRenderState;
		array<TProgData>		aProgramData;
		array<TTexBindParams>	aTexBind;
		array<TRTAttachParams>	aRTs;
		frect					sViewport;
		bool					bChangeRS;
		///
		TPPPass(): bChangeRS(false) {}
	};
	_CREATE_META_OBJECT_FD( TPPPass );


	struct TPostProcess
	{
		array<TPPPass>			aPPPasses;
		array<TInputTexture>	aSrcTex;
		array<TInputTexture>	aResult;
		array<TRenderTarget>	aRTs;
		array<TLoadedTexture>	aLoadTex;
		array<string_array_t>	aPasses;
		e_post_process::type	eType;
		///
		TPostProcess(): eType(e_post_process::UNKNOWN) {}
	};
	_CREATE_META_OBJECT_FD( TPostProcess );

	
	struct TBindTexture
	{
		const CTexturePtr*	pTexture;
		uint				uSamplerID;
		uint8				uStage;
		///
		TBindTexture(): pTexture(nullptr), uSamplerID(0), uStage(0) {}
		TBindTexture(const CTexturePtr *tex, uint8 stage, uint samp = 0): pTexture(tex), uSamplerID(samp), uStage(stage) {}
	};


	struct TPPRenderTarget
	{
		const CTexturePtr*	pTexture;
		e_fbo_attach::type	eAttach;
		uint				uLayer;
		uint				uLOD;
		///
		TPPRenderTarget():
			pTexture(nullptr), eAttach(e_fbo_attach::COLOR_0), uLayer(0), uLOD(0) {}
		TPPRenderTarget(const CTexturePtr *tex, e_fbo_attach::type attach, uint layer, uint lod):
			pTexture(tex), eAttach(attach), uLayer(layer), uLOD(lod) {}
	};


	struct TPPTypes
	{
		enum ETextureType
		{
			UNKNOWN			= 0,
			TEX_2D			= 1,	// GL_TEXTURE_2D
			TEX_2D_A		= 2,	// GL_TEXTURE_2D_ARRAY
			TEX_3D			= 3,	// GL_TEXTURE_3D
			CUBE_MAP		= 4,	// GL_TEXTURE_CUBE_MAP
			CUBE_MAP_A		= 5,	// GL_TEXTURE_CUBE_MAP_ARRAY
			TEX_2D_MS		= 6,	// GL_TEXTURE_2D_MULTISAMPLE
			TEX_2D_MSA		= 7,	// GL_TEXTURE_2D_MULTISAMPLE_ARRAY
		};
	};

//-------------------------------------------------------------------

}	// EngineResource
}	// Engine

#endif	// _UX_POST_PROCESS_TYPES_H